package com.samphanie.auiu.admin.controller;

import com.samphanie.auiu.admin.feign.IAuiuAuthService;
import com.samphanie.auiu.common.dto.CreateOrUpdateClientDto;
import com.samphanie.auiu.common.utils.ApiResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author ZSY
 * @email 1451691457@qq.com
 */
@Api(tags = "客户端管理")
@RestController
@RequestMapping("/admin")
@RequiredArgsConstructor
public class OauthClientController {

    private final IAuiuAuthService authService;

    @ApiOperation("客户端列表")
    @GetMapping("/clients")
    public ApiResponse<?> findAllClients() {
        return authService.findAllClients();
    }

    @ApiOperation("新增客户端")
    @PostMapping("/clients")
    public ApiResponse<?> addClient(@RequestBody CreateOrUpdateClientDto client) {
        return authService.addClient(client);
    }

    @ApiOperation("编辑客户端")
    @PutMapping("/clients/{clientId}")
    public ApiResponse<?> updateClient(@PathVariable String clientId, @RequestBody CreateOrUpdateClientDto client) {
        return authService.updateClient(clientId, client);
    }

    @ApiOperation("删除客户端")
    @DeleteMapping("/clients/{clientId}")
    public ApiResponse<?> deleteClient(@PathVariable String clientId) {
        return authService.deleteClient(clientId);
    }

}
